import requests
# 定义类 - 大驼峰  接口对象层
class TpshopRegisterApi(object):
    # 定义方法
    def register(self, req_data):
        session = requests.Session()
        session.get(
            url="http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg&r=0.08615941291685969")

        resp = session.post(url="http://hmshop-test.itheima.net/Home/User/reg.html",

                            data={"username": "13612568888", "verify_code": "8888",
                                  "password": "123456", "password2": "123456"})
        return resp


# 自测
if __name__ == '__main__':
    # 创建实例
    tpshop_register = TpshopRegisterApi()  # 强调，千万别丢()
    # 准备请求体数据
    req_data = {"username": "13612563478", "verify_code": "8888",
                "password": "123456", "password2": "123456"}
    # 使用实例，调用方法。
    resp = tpshop_register.register(req_data)
    # 打印注册的响应结果
    print("注册结果：", resp.json())
